package come.tool.Fighting;

import com.tool.ModerateTask.Hero;
import com.tool.PanelDisplay.PetPanelShow;
import com.tool.PlayerKill.PKSys;
import com.tool.image.ImageMixDeal;
import com.tool.image.ManimgAttribute;
import com.tool.imagemonitor.FightingMonitor;
import com.tool.pet.PetProperty;
import com.tool.role.RoleData;
import com.tool.tcp.GetTcpPath;
import com.tool.tcp.SpriteFactory;
import com.tool.tcpimg.UIUtils;
import com.tool.time.Limit;
import com.tool.time.TimeLimit;
import come.tool.FightingData.BattleEnd;
import come.tool.FightingData.FightingEndD;
import come.tool.FightingEffect.EffectType;
import come.tool.handle.HandleState;
import come.tool.handle.HandleType;
import org.come.Frame.MsgJframe;
import org.come.Frame.PartnerArenaJframe;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.FrameMessageChangeJpanel;
import org.come.Jpanel.GameJpanel;
import org.come.Jpanel.ZhuJpanel;
import org.come.bean.FightOperation;
import org.come.bean.LoginResult;
import org.come.bean.NpcCureBean;
import org.come.bean.PrivateData;
import org.come.control.AssetControl;
import org.come.entity.Fly;
import org.come.entity.RoleSummoning;
import org.come.model.Gamemap;
import org.come.mouslisten.PetAddPointMouslisten;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.thread.TimeControlRunnable;
import org.come.until.*;

import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class FightingMixDeal {
    /**
     * 回合时间 60秒
     */
    public static final int ROUND_TIME = 60000;//战斗时间倒计时
    /**
     * 玩家自动操作时间
     */
    public static final int AUTOMATION_PLAYER = 2000;//战斗等待时间和 怨气怒气不显示
    /**
     * 召唤兽自动操作时间
     */
    public static final int AUTOMATION_PET = 750;
    /**
     * 战斗类型
     */
    public static int BattleType;
    /**
     * 战斗编号
     */
    public static int FightingNumber;
    /**
     * 回合数
     */
    public static int CurrentRound;
    public static Fightingimage XZImage;

    // 延迟时间
    public static long CorrectTime = 0;
    // 播放类型
    public static long roundType = 0;
    // 当前时间
    public static long time;
    // 当前战斗状态
    public static int State = 0;
    // 战斗播放指令
    public static Map<Integer, Statelist> BattlefieldPlay = new HashMap<>();
    // 法术显示
    public static List<SkillSpell> skills = new ArrayList<>();
    // //当前战斗数据
    public static List<Fightingimage> CurrentData = new ArrayList<>();
    // 时间
    public static long systime = System.currentTimeMillis();
    public static long cha = 0;
    public static BuffUtil buffUtil = new BuffUtil();
    // 那个阵营属于左边 主视角的阵营
    public static int camp = 1;
    public static int man = -1;
    public org.come.control.RoleSumminCloseControl roleSumminCloseControl;
    public static Map<String, ImageIcon> imageIconMap;

    /**
     * 屏幕调整刷新位置
     */
    public static void changepath() {
        for (int i = 0; i < CurrentData.size(); i++) {
            CurrentData.get(i).tiaoz(camp);
        }
        buffUtil.ViewPath(camp);
    }

    // 剩余自动回合
    public static int zdhh = 0;
    // 当前播放的音乐
    public static String Music1 = "";

    /**
     * 进度处理
     *
     * @return
     */
    public synchronized static void PalyProgress(long pass) {
        time += pass;
        if (pass == 0) {
            return;
        }
        try {
            for (int i = 0, size = CurrentData.size(); i < size; i++) {
                CurrentData.get(i).addTime(pass);
            }
            long DieTime = (long) (pass * 1.6);
            for (int i = FightingMixDeal.skills.size() - 1; i >= 0; i--) {
                if (FightingMixDeal.skills.get(i).getDietime(DieTime)) {
                    FightingMixDeal.skills.remove(i);
                }
            }
            HandleType.getHandleById(State).handle(pass);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    // 切换背景图
    public static void CgImg(int id) {
//        id %= MAX;
//        id++;
        if (id != bjid) {
            bjid = id;
            bj = new ImageIcon("resource/NewMap/" + bjid + ".png").getImage();
        }
        if (yq == null || nq == null) {
            yq = new ImageIcon("resource/NewMap/yq.png").getImage();
            nq = new ImageIcon("resource/NewMap/nq.png").getImage();
        }
        final String all = "1234567890";
        final String[] split2;
        final String[] split = split2 = all.split("");
        final int length = split2.length;
        int i = 0;
        while (i < length) {
            final String s = split2[i];
            ImageIcon image3;
            if (s.charAt(0) >= '0' && s.charAt(0) <= '9') {
                image3 = new ImageIcon("inkImg/number/npk/cb/number" + s + ".png");
            } else {
                image3 = new ImageIcon("inkImg/number/npk/cb/number" + s + ".png");
            }
            FightingMixDeal.imageIconMap.put(s, image3);
            ++i;
        }
    }
//    {
////        id %= MAX;
////        id++;
//        if (id != bjid) {
//            bjid = id;
//            bj = new ImageIcon("resource/NewMap/" + bjid + ".png").getImage();
//        }
//        if (yq == null || nq == null) {
//            yq = new ImageIcon("resource/NewMap/yq.png").getImage();
//            nq = new ImageIcon("resource/NewMap/nq.png").getImage();
//        }
//    }

    private static int MAX = 5;
    private static int bjid;
    private static Image bj;
    private static Image yq;
    public static String yqz;
    private static Image nq;
    public static String nqz;

    /**
     * 字段名:di 第<br>
     * 字段名:bout 回合<br>
     * 字段名:se 第几个回合数<br>
     *
     * @time 2019年12月28日 上午10:45:03<br>
     */
    //TODO 战斗状态画图
    private static String di = "第 ";
    private static String bout = " 回合";
    private static String se = Integer.toString(CurrentRound);
    private static int seInt = CurrentRound;


    /**
     * 画图
     */
    public static void Drawing(Graphics2D g, long dietime) {
        try {
            g.drawImage(FightingMixDeal.bj, 0, 0, ScrenceUntil.Screen_x, ScrenceUntil.Screen_y, null);
            FightingMixDeal.buffUtil.draw((Graphics) g);
            int i = 0;
            int size = FightingMixDeal.CurrentData.size();
            while (i < size) {
                g.setColor(Color.yellow);
                ((Fightingimage) FightingMixDeal.CurrentData.get(i)).Drawing((Graphics) g, dietime);
                ++i;
            }
            i = 0;
            size = FightingMixDeal.CurrentData.size();
//            while (i < size) {
//                g.setColor(Color.yellow);
//                ((Fightingimage)FightingMixDeal.CurrentData.get(i)).Drawing3((Graphics)g, dietime);
//                ++i;
//            }
//            i = 0;
            while (i < FightingMixDeal.skills.size()) {
                ((SkillSpell) FightingMixDeal.skills.get(i)).draw((Graphics) g);
                ++i;
            }
            i = 0;
            size = FightingMixDeal.CurrentData.size();
            while (i < size) {
                ((Fightingimage) FightingMixDeal.CurrentData.get(i)).Drawing2((Graphics) g, dietime);
                ++i;
            }
            i = 0;
            size = FightingMixDeal.CurrentData.size();
            while (i < size) {
                ((Fightingimage) FightingMixDeal.CurrentData.get(i)).drawSay((Graphics) g);
                ++i;
            }
            g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
            if (FightingMixDeal.State <= 2) {
                final long surplus = 60L - FightingMixDeal.time / 1000L;//回合剩余时间
                final String times = (surplus < 0L) ? "0" : (surplus + "");
                final String[] ss = times.split("");
                int j = 0;
                while (j < ss.length) {
                    g.drawImage(((ImageIcon) FightingMixDeal.imageIconMap.get(ss[j])).getImage(), ScrenceUntil.Screen_x / 2 - 20 + j * 30 + 8 * j, 70, null);
                    ++j;
                }
            }
            g.setFont(new Font("楷体", 0, 18));
            g.setColor(Color.BLACK);
            g.drawString(FightingMixDeal.di, 31, 80);
            g.drawString(FightingMixDeal.di, 31, 80);
            g.drawString(FightingMixDeal.bout, 41 + FightingMixDeal.se.length() * 11, 81);
            g.drawString(FightingMixDeal.bout, 41 + FightingMixDeal.se.length() * 11, 81);
            g.setColor(UIUtils.COLOR_FightingRound);
            g.drawString(FightingMixDeal.di, 30, 80);
            g.drawString(FightingMixDeal.di, 30, 80);
            g.drawString(FightingMixDeal.di, 30, 80);
            g.drawString(FightingMixDeal.di, 30, 80);
            g.drawString(FightingMixDeal.di, 30, 80);
            g.drawString(FightingMixDeal.bout, 40 + FightingMixDeal.se.length() * 11, 80);
            g.drawString(FightingMixDeal.bout, 40 + FightingMixDeal.se.length() * 11, 80);
            g.drawString(FightingMixDeal.bout, 40 + FightingMixDeal.se.length() * 11, 80);
            g.drawString(FightingMixDeal.bout, 40 + FightingMixDeal.se.length() * 11, 80);
            g.drawString(FightingMixDeal.bout, 40 + FightingMixDeal.se.length() * 11, 80);
            if (FightingMixDeal.seInt != FightingMixDeal.CurrentRound) {
                FightingMixDeal.seInt = FightingMixDeal.CurrentRound;
                FightingMixDeal.se = Integer.toString(FightingMixDeal.CurrentRound);
            }
            g.setFont(new Font("楷体", 0, 18));
            g.setColor(UIUtils.COLOR_FightingRound_Black);
            g.drawString(FightingMixDeal.se, 51, 80);
            g.drawString(FightingMixDeal.se, 51, 80);
            g.setColor(Color.yellow);
            g.drawString(FightingMixDeal.se, 50, 80);
            g.setFont(UIUtils.TEXT_FONT);
            if (FightingMixDeal.yqz != null) {
                g.drawImage(FightingMixDeal.yq, ScrenceUntil.Screen_x / 2 - 50, 15, null);
                g.drawString(FightingMixDeal.yqz, ScrenceUntil.Screen_x / 2 - 26, 30);
            }
            if (FightingMixDeal.nqz != null) {
                g.drawImage(FightingMixDeal.nq, ScrenceUntil.Screen_x / 2 + 30, 15, null);
                g.drawString(FightingMixDeal.nqz, ScrenceUntil.Screen_x / 2 + 55, 30);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }


//    {
//        try {
//            g.drawImage(bj, 0, 0, ScrenceUntil.Screen_x, ScrenceUntil.Screen_y, null);
//            buffUtil.draw(g);
//            for (int i = 0, size = CurrentData.size(); i < size; i++) {
//                g.setColor(Color.yellow);
//                CurrentData.get(i).Drawing(g, dietime);
//            }
//            for (int i = 0; i < skills.size(); i++) {
//                skills.get(i).draw(g);
//            }
//            for (int i = 0, size = CurrentData.size(); i < size; i++) {
//                CurrentData.get(i).Drawing2(g, dietime);
//            }
//            for (int i = 0, size = CurrentData.size(); i < size; i++) {
//                CurrentData.get(i).drawSay(g);
//            }
//    		g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
//            if (State <= HandleState.HANDLE_PET) {
//                g.setFont(new Font("隶书", Font.BOLD, 64));
//                long surplus = (60 - time / 1000);
//                String times = surplus < 0 ? "0" : surplus + "";
//                g.setColor(UIUtils.COLOR_FightingRound_Black);
//                g.drawString(times, ScrenceUntil.Screen_x / 2 - 34, 111);
//                g.setColor(Color.RED);
//                g.drawString(times, ScrenceUntil.Screen_x / 2 - 33, 110);
//            }
////            if (zdhh != 0) {
////            	g.setFont(new Font("隶书", Font.BOLD, 18));
////                g.setColor(UIUtils.COLOR_FightingRound_Black);
////                g.drawString("剩余", ScrenceUntil.Screen_x - 134, ScrenceUntil.Screen_y -  161);
////                g.setColor(new Color(198,166,8));
////                g.drawString("剩余", ScrenceUntil.Screen_x - 135, ScrenceUntil.Screen_y -  160);
////        		String count = zdhh +"";
////        		g.setColor(UIUtils.COLOR_FightingRound_Black);
////        		g.drawString( count , ScrenceUntil.Screen_x - 92, ScrenceUntil.Screen_y -  161);
////        		g.setColor(Color.RED);
////        		g.drawString( count , ScrenceUntil.Screen_x - 93, ScrenceUntil.Screen_y -  160);
////        		g.setColor(UIUtils.COLOR_FightingRound_Black);
////        		g.drawString("回合", ScrenceUntil.Screen_x - 51, ScrenceUntil.Screen_y -  161);//51, 121
////        		g.setColor(new Color(198,166,8));
////        		g.drawString("回合", ScrenceUntil.Screen_x - 52,  ScrenceUntil.Screen_y - 160);
////            }
//            g.setFont(UIUtils.TEXT_HYK20);
//            g.setColor(UIUtils.COLOR_FightingRound_Black);
//            g.drawString(di, 10, 76);
//            g.drawString(bout,56, 77);
//            g.setColor(UIUtils.COLOR_FightingRound);
//            g.drawString(di, 10, 76);
//            g.drawString(bout, 57, 77);
//            if (seInt != CurrentRound) {
//                seInt = CurrentRound;
//                se = Integer.toString(CurrentRound);
//            }
//            g.setFont(UIUtils.TEXT_FONT62);
//            g.setColor(UIUtils.COLOR_FightingRound_Black);
//            g.drawString(se, 41, 76);
//            g.setColor(Color.yellow);
//            g.drawString(se, 42, 77);
//            g.setFont(UIUtils.TEXT_FONT);
//
//            if (yqz != null) {
//                g.drawImage(yq, ScrenceUntil.Screen_x / 2 - 50, 15, null);
//                g.drawString(yqz, ScrenceUntil.Screen_x / 2 - 20, 30);
//            }
//            if (nqz != null) {
//                g.drawImage(nq, ScrenceUntil.Screen_x / 2 + 3, 15, null);
//                g.drawString(nqz, ScrenceUntil.Screen_x / 2 + 33, 30);
//            }
//        } catch (Exception e) {
//            // TODO: handle exception
//        }
//    }

    /**
     * 切换状态
     */
    public static void changeState(int state) {
        if (state == HandleState.HANDLE_END || state == HandleState.HANDLE_PLAYER || state == HandleState.HANDLE_PET
                || state == HandleState.HANDLE_WAIT) {
            CorrectTime = 0;
        }
        State = state;
    }

    /**
     * 回合结束后 找出死亡切不为玩家的清除
     */
    public static void qingchusiwang() {
        int bbman = myman() + 5;
        for (int i = CurrentData.size() - 1; i >= 0; i--) {
            FightingManData data = CurrentData.get(i).getFightingManData();
            if (data.getHp_Current() <= 0) {
                if (data.getType() == 0) {
                    continue;
                }
                if (data.getType() == 2 && !(data.getZs()>0)) {
                    continue;
                }
                if (isFightType()) {
                    if (data.getType() == 1 && FightingMixDeal.camp == data.getCamp() && bbman == data.getMan()
                            && TimeLimit.getLimits().getLimit("VIP") == null) {
                        RoleSummoning bb = Article.bb(data.getId());
                        if (bb != null) {
                            bb.setBasishp(PetProperty.getPetHMASp(bb)[0]);
                            bb.setBasismp(PetProperty.getPetHMASp(bb)[1]);
                            bb.addFaithful(-10);
                            Article.souxie(bb);
                            try {
                                SendRoleAndRolesummingUntil.sendRoleSumming(bb);
                            } catch (Exception e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                        }
                    }
                }
                CurrentData.remove(i);
            }
        }
    }

    /**
     * 根据接出流程战斗事件FightingEvents
     */
    public static List<StateProgress> AnalysisFightingEvents(FightingEvents fightingEvents, int JD) {
        List<StateProgress> States = new ArrayList<>();
        try {
            FightingState Originator = fightingEvents.getOriginator();
            if (Originator != null) {
                String type = Originator.getStartState();
                if ("召唤".equals(type) || "召回".equals(type) || "闪现".equals(type)) {
                    StateProgress progress = EffectType.getEffectById(3).analysisAction(Originator, -1);
                    if (progress != null) {
                        States.add(progress);
                    }
                } else if ("逃跑成功".equals(type) || "逃跑失败".equals(type)) {
                    int path = FightingMixDeal.CurrentData(Originator.getCamp(), Originator.getMan());

                    if (path != -1) {
                        StateProgress progress = EffectType.getEffectById(4).analysisAction(Originator, path);
                        SkillSpell skillSpell = new SkillSpell();
                        Fightingimage fightingimage = FightingMixDeal.CurrentData.get(path);
                        if ("逃跑成功".equals(type)) {
                            skillSpell = new SkillSpell(GetTcpPath.getSkillTcp("成功"), fightingimage.getX(), fightingimage.getY());
                        } else if ("逃跑失败".equals(type)) {
                            skillSpell = new SkillSpell(GetTcpPath.getSkillTcp("失败"), fightingimage.getX(), fightingimage.getY());
                        }
                        progress.setSpell(skillSpell);
                        if (progress != null) {
                            States.add(progress);
                        }
                    }
                } else if ("捕捉失败".equals(type) || "捕捉成功".equals(type)) {
                    int path = FightingMixDeal.CurrentData(Originator.getCamp(), Originator.getMan());
                    if (path != -1) {
                        StateProgress progress = EffectType.getEffectById(5).analysisAction(Originator, path);
                        if (progress != null) {
                            States.add(progress);
                        }
                    }
                }
            } else {
                for (int i = 0; i < fightingEvents.getAccepterlist().size(); i++) {
                    FightingState fightingState = fightingEvents.getAccepterlist().get(i);
                    String type = fightingState.getStartState();
                    StateProgress progress = null;
                    if ("召唤".equals(type) || "召回".equals(type) || "闪现".equals(type)) {
                        progress = EffectType.getEffectById(3).analysisAction(fightingState, -1);
                    } else {
                        int path = FightingMixDeal.CurrentData(fightingState.getCamp(), fightingState.getMan());
                        if (path != -1) {
                            if ("移动".equals(type) || "瞬移".equals(type) || "遁地".equals(type)) {
                                progress = EffectType.getEffectById(1).analysisAction(fightingState, path);
                            } else if ("技能移动".equals(type)) {
                                progress = EffectType.getEffectById(6).analysisAction(fightingState, path);
                            } else {
                                progress = EffectType.getEffectById(2).analysisAction(fightingState, path);
                            }
                        }
                    }
                    if (progress != null) {
                        if (progress.getSpell() != null) {
                            progress.getSpell().setRound(JD);
                        }
                        States.add(progress);
                    }
                }
            }
        } catch (Exception e) {
            // TODO: handle exception
            System.err.println(GsonUtil.getGsonUtil().getgson().toJson(fightingEvents));
            e.printStackTrace();
        }
        return States;
    }

    /**
     * 找到删除指定位置
     */
    public static void depath(int mycamp, int myman) {
        int bbman = FightingMixDeal.myman() + 5;
        for (int i = 0; i < CurrentData.size(); i++) {
            FightingManData data = CurrentData.get(i).getFightingManData();
            if (data.getCamp() == mycamp && data.getMan() == myman) {
                if (FightingMixDeal.camp == data.getCamp() && bbman == data.getMan()) {
                    RoleSummoning bb = Article.bb(data.getId());
                    if (bb != null) {
                        if (FightingMixDeal.isFightType() && TimeLimit.getLimits().getLimit("VIP") == null) {
                            if (data.getHp_Current() <= 0) {
                                bb.setBasishp(PetProperty.getPetHMASp(bb)[0]);
                                bb.setBasismp(PetProperty.getPetHMASp(bb)[1]);
                                bb.addFaithful(-10);
                                Article.souxie(bb);
                            }
                            SendRoleAndRolesummingUntil.sendRoleSumming(bb);
                        }
                    }
                }
                CurrentData.remove(i);
                break;
            }
        }
    }

    /**
     * 进入回合战斗状态
     */
    public static void RoundFighting() {
        FormsManagement.HideForm(46);
        FormsManagement.HideForm(34);
        FormsManagement.HideForm(631);
        FormsManagement.HideForm(6);
        FormsManagement.HideForm(40);
        ZhuFrame.getZhuJpanel().HideBeastBtn();
    }

    /**
     * 进入回合决策状态
     */
    public static void RoundDecision() {
        try {

            FightingMixDeal.time = 0L;
            ++FightingMixDeal.CurrentRound;
            if ("取消".equals(ZhuFrame.getZhuJpanel().getZidong().getText()) && FightingMixDeal.zdhh-- <= 0) {
                ZhuFrame.getZhuJpanel().getZidong().setText("自动");
            }
            ZhuFrame.getZhuJpanel().HideBeastBtn();
            if (FightingMixDeal.camp != -1) {
                ZhuFrame.getZhuJpanel().ShowManBtn(isLL());
                changeState(FightingMixDeal.State = 1);
            } else {
                changeState(FightingMixDeal.State = 3);
            }
            int i = FightingMixDeal.CurrentData.size() - 1;
            while (i >= 0) {
                ((Fightingimage) FightingMixDeal.CurrentData.get(i)).getmsg();
                --i;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 观战退出战斗场景
     */
    public static void FightingEnd() {
        GameJpanel.alpha = 0.3f;
        // 结束战斗返回场景音乐
        changeState(State = HandleState.USUAL);
        BattlefieldPlay.clear();
        time = 0;
        CorrectTime = 0;
        CurrentRound = 0;

        if (Music.MusicNew != null) {
            if ("1".equals(Music.MusicNew)) {
                Music.addbeijing(UserMessUntil.getAllmapbean().getAllMap().get(ImageMixDeal.userimg.getRoleShow().getMapid() + "").getMusic() + "o.mp3");
            } else if ("2".equals(Music.MusicNew)) {
                Music.addbeijing(UserMessUntil.getAllmapbean().getAllMap().get(ImageMixDeal.userimg.getRoleShow().getMapid() + "").getMusic() + ".mp3");
            }
        }
        OutFighting();
    }

    /**
     * 战斗结束发送服务器
     */
    public static void FightingEnd(BattleEnd battleEnd) {
        GameJpanel.alpha = 0.3f;
        // 结束战斗返回场景音乐
        changeState(State = HandleState.USUAL);
        BattlefieldPlay.clear();
        time = 0;
        CorrectTime = 0;
        CurrentRound = 0;

        Music.addbeijing(UserMessUntil.getAllmapbean().getAllMap()
                .get(ImageMixDeal.userimg.getRoleShow().getMapid() + "").getMusic()
                + ".mp3");
        if (battleEnd == null) {
            FightingEndD fightingEndD = new FightingEndD();
            fightingEndD.setFightingsumber(FightingNumber);
            String sendMes = Agreement.FightingendAgreement(GsonUtil.getGsonUtil().getgson().toJson(fightingEndD));
            SendMessageUntil.toServer(sendMes);
        } else if (FightingMixDeal.camp != -1) {
            FrameMessageChangeJpanel.addtext(6, battleEnd.getCamp() == FightingMixDeal.camp ? "战斗胜利" : "战斗失败", null,
                    null);
            if (battleEnd.getTaskDaily() != null) {
                PKSys.getPkSys().upPK(battleEnd.getTaskDaily());
            }
            AssetControl.asset(battleEnd.getAssetUpdate());
            Hero.getHero().addTask(battleEnd.getTaskn());
            if (battleEnd.getMsg() != null && !"".equals(battleEnd.getMsg())) {
                String[] vs = battleEnd.getMsg().split("\\|");
                for (int i = 0; i < vs.length; i++) {
                    FrameMessageChangeJpanel.addtext(6, vs[i], null, null);
                }
            }
            if (battleEnd.getArenaBean() != null) {
                PartnerArenaJframe.getPartnerArenaJframe().getPartnerArenaMainPanel().showView(battleEnd.getArenaBean());
            }
        }
        OutFighting();
    }

    /**
     * 找到玩家的位置
     */
    public static int myman() {
        return man;
    }

    /**
     * 找到玩家或者玩家召唤兽数据
     */
    public static Fightingimage getdata(int type) {
        return CurrentDataImage(camp, myman() + type * 5);
    }

    /**
     * 判断是否还有召唤兽
     */
    public static boolean MyBeastLifeAndDeath() {
        return CurrentDataImage(camp, myman() + 5) != null;
    }

    /**
     * 判断是否是 人死 召唤兽死 true 是
     */
    public static boolean isLL() {
        Fightingimage fightingimage = CurrentDataImage(camp, man + 5);
        if (fightingimage == null || fightingimage.getFightingManData().getHp_Current() <= 0) {
            fightingimage = CurrentDataImage(camp, man);
            if (fightingimage == null || fightingimage.getFightingManData().getHp_Current() <= 0) {
                return true;
            }
        }
        return false;
    }

    /**
     * 根据阵营 和 位置找到在CurrentData的位置
     */
    public static int CurrentData(int camp, int man) {
        for (int i = 0; i < CurrentData.size(); i++) {
            if (CurrentData.get(i).getFightingManData().getCamp() == camp
                    && CurrentData.get(i).getFightingManData().getMan() == man) {
                return i;
            }
        }
        return -1;
    }

    /**
     * 根据阵营 和 位置找到在CurrentData的位置
     */
    public static Fightingimage CurrentDataImage(int camp, int man) {
        for (int i = 0; i < CurrentData.size(); i++) {
            Fightingimage fightingimage = CurrentData.get(i);
            if (fightingimage.getFightingManData().getCamp() == camp && fightingimage.getFightingManData().getMan() == man) {
                return CurrentData.get(i);
            }
        }
        return null;
    }

    /**
     * 返回玩家或者召唤兽的战斗FightingState
     */
    public static FightingState FightingState(String type, int type1) {
        if (type1 == 0) {
            return new FightingState(camp, myman(), type);
        } else {
            return new FightingState(camp, myman() + 5, type);
        }
    }

    /**
     * 初始化战斗数据的的方法
     */
    public static void CurrentData(List<FightingManData> fightingManDatas, String buff, FightingManData mydata) {
        buffUtil.buffs.clear();
        int my_camp = -1;
        int my_man = -1;
        if (mydata != null) {
            my_camp = mydata.getCamp();
            my_man = mydata.getMan();
            nqz = mydata.getNqz() + "";
            yqz = mydata.getYqz() + "";
            buffUtil.SXSkill(mydata.cxxx("技能"));
        } else {
            buffUtil.skills.clear();
        }
        buffUtil.CS(buff, my_camp);

        // TODO 根据当前地图切换战斗背景
        LoginResult loginResult = RoleData.getRoleData().getLoginResult();
        Gamemap gamemap = UserMessUntil.getAllmapbean().getAllMap().get(loginResult.getMapid() + "");
        CgImg(Integer.valueOf(gamemap.getBackground()));
        camp = my_camp;
        man = my_man;
        if (CurrentData == null) {
            CurrentData = new ArrayList<>();
        } else {
            CurrentData.clear();
        }
        int xz = 15;
        while (fightingManDatas.size() != 0) {
            for (int i = fightingManDatas.size() - 1; i >= 0; i--) {
//              int man=fightingManDatas.get(i).getMan();
//              if (man<10) {man=man/5*5+(5-man%5);}
                if (fightingManDatas.get(i).getMan() >= xz) {
                    CurrentData.add(new Fightingimage(fightingManDatas.remove(i), my_camp));
                }
            }
            if (xz > 10) {
                xz -= 5;
            } else {
                xz--;
            }
        }
        if (camp == -1) {
            ZhuFrame.getZhuJpanel().getZidong().setText("离开");
            ZhuFrame.getZhuJpanel().setZidong111();
        } else if (zdhh > 0) {
            ZhuFrame.getZhuJpanel().getZidong().setText("取消");
        } else {
            ZhuFrame.getZhuJpanel().getZidong().setText("自动");
        }
        FightingMixDeal.CurrentRound = 1;
        ZhuFrame.getZhuJpanel().intoFighting();
        if (FightingMixDeal.BattleType == 101) {
            if (FormsManagement.getInternalForm2(5) != null) {
                if (FormsManagement.getframe(5).isVisible()) {
                    FormsManagement.HideForm(5);
                }
            }
        } else if (FightingMixDeal.BattleType == 103) {
            if (FormsManagement.getInternalForm2(111) != null) {
                if (FormsManagement.getframe(111).isVisible()) {
                    FormsManagement.HideForm(111);
                }
            }
        }
    }

    /**
     * 退出战斗场景
     */
    public static void OutFighting() {
        if ("玉枢返虚丸".equals(getMp())) {
            try {
                addPetFathifulMP(UserMessUntil.getChosePetMes());
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        if ("六脉化神丸".equals(getHp())) {
            try {
                addPetFathifulHP(UserMessUntil.getChosePetMes());
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        //飞行器相关
        ImageMixDeal.userimg.getRoleShow().getPlayer_Paths().clear();
        if (ImageMixDeal.userimg.getRoleShow().getFly_id() > 0) {
            if (ZhuJpanel.getListFly() != null && ZhuJpanel.getListFly().size() > 0) {
                for (Fly fly : ZhuJpanel.getListFly()) {
                    if (fly.getFlytid() == ImageMixDeal.userimg.getRoleShow().getFly_id()) {
//                        //system.out.println(fly.getFuel());
                        if (fly.getFuel() > 0) {
                            String sendMesa = Agreement.useflyAgreement("flyxh|" + fly.getMid());
                            SendMessageUntil.toServer(sendMesa);
                            ZhuFrame.getZhuJpanel().addPrompt2("消耗了10点然灵值!");
                        }
                        if (fly.getFuel() <= 0) {
                            ZhuFrame.getZhuJpanel().addPrompt2("然灵值不足已无法飞行，请及补充!");
                            ImageMixDeal.userimg.getRoleShow().setFly_id(0);
                            ManimgAttribute.isdaiji = true;
                            ImageMixDeal.userimg.changeskin(null);
                            ManimgAttribute.ISFLY = false;
                        }
                    }
                }
            }
        }
        FightingMixDeal.buffUtil.isMcqh = false;
        ZhuFrame.getZhuJpanel().outFighting();
        FightingMixDeal.CurrentData.clear();
        FightingMixDeal.BattlefieldPlay.clear();
        FightingMixDeal.skills.clear();
        FightingMixDeal.Music1 = "";
        FightingMixDeal.FightingNumber = -1;
        SpriteFactory.ResetAndRemove();
        FightingMixDeal.nqz = null;
        FightingMixDeal.yqz = null;
        FightingMixDeal.buffUtil.buffs.clear();
        PetPanelShow.refresh();
        TimeControlRunnable.addAllTask(null);
    }

    public static int x = -1;
    public static int y = -1;

    //TODO 鼠标悬停NPC名字变色（战斗）

    /**
     * 判断是否移动到人物上 监听触发
     */
    public static void nameColor(int x, int y) {
        FightingMixDeal.x = x;
        FightingMixDeal.y = y;
        //玩家操作或召唤兽操作
        if (State == HandleState.HANDLE_PLAYER || State == HandleState.HANDLE_PET) {
            // 只会触发野怪召唤兽人物
            for (int i = 0; i < CurrentData.size(); i++) {// 不为灵宝和宝宝
                //  0属于玩家  1属于召唤兽  2属于野怪3属于灵宝 4属于宝宝
                if (CurrentData.get(i).getFightingManData().getType() < 3) {
                    if (CurrentData.get(i).isContains(x, y)) {// 触发监听
                        if (MessagrFlagUntil.ImgFlagImg.equals(MessagrFlagUntil.MOUSE1)) {
                            MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE12);
                        }
                        // 名字变色
                        CurrentData.get(i).setNameColor(UIUtils.COLOR_NPC_SELECT);
                    } else {
                        if (MessagrFlagUntil.ImgFlagImg.equals(MessagrFlagUntil.MOUSE12)) {
                            MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE1);
                        }
                        CurrentData.get(i).setDefaultNameColor();
                    }
                }
            }
        }
    }

    /**
     * 判断是否移动到人物上 监听触发
     */
    public static void status() {
        if (x == -1 || y == -1) {
            return;
        }
        //玩家操作或召唤兽操作
        if (State == HandleState.HANDLE_PLAYER || State == HandleState.HANDLE_PET) {
            // 只会触发野怪召唤兽人物
            for (int i = 0; i < CurrentData.size(); i++) {// 不为灵宝和宝宝
                //  0属于玩家  1属于召唤兽  2属于野怪3属于灵宝 4属于宝宝
                if (CurrentData.get(i).getFightingManData().getType() != 3
                        && CurrentData.get(i).getFightingManData().getType() != 4) {
                    if (CurrentData.get(i).isContains(x, y)) {// 触发监听
                        MsgJframe.getJframe().getJapnel().battleState(CurrentData.get(i).getFightingManData());
                    }
                }
            }
        }
    }

    /**
     * 判断是否点击到人物上 监听触发
     */
    public static void MonitorTrigger(int x, int y) {
        if (State == HandleState.HANDLE_PLAYER || State == HandleState.HANDLE_PET) {
            // 只会触发野怪召唤兽人物
            for (int i = 0; i < CurrentData.size(); i++) {// 不为灵宝和宝宝
                if (CurrentData.get(i).getFightingManData().getType() != 3
                        && CurrentData.get(i).getFightingManData().getType() != 4) {
                    if (CurrentData.get(i).isContains(x, y)) {// 触发监听
                        FightingMonitor.Fighting(CurrentData.get(i));
                        return;
                    }
                }
            }
            SkillTx skillTx = buffUtil.MonitorBuff(x, y);
            if (skillTx != null) {
                if (skillTx.isIs()) {
                    return;
                }
                if (State != HandleState.HANDLE_PLAYER) {
                    return;
                }
                Fightingimage fightingimage = getdata(0);
                if (fightingimage == null) {
                    return;
                }
                if (skillTx.getId() >= 9001 && skillTx.getId() <= 9500) {// 套装技能
                    if (fightingimage.getFightingManData().getNqz() < 100) {
                        ZhuFrame.getZhuJpanel().addPrompt2("你怒气值还未达到100,无法释放" + skillTx.getSkill().getSkillname());
                        return;
                    }
                }
                FightOperation operation = new FightOperation();
                operation.Record(fightingimage.getFightingManData().getCamp(), fightingimage.getFightingManData()
                        .getMan(), 1, skillTx.getSkill().getSkillname());
                FightingEvents events = FightingMonitor.AttackGenerate(operation);
                FightingMonitor.FightingOperation(events);
                skillTx.setIs(true);
                ZhuFrame.getZhuJpanel().addPrompt2("你释放了" + skillTx.getSkill().getSkillname());
                return;
            }
        }
    }

    /**
     * 加载音乐
     */
    public static void LoadMusic(String yinyue) {
        if (yinyue != null && !"".equals(yinyue)) {
            if (!Music1.equals(yinyue)) {
                Music1 = yinyue;
                Music.addyinxiao(yinyue + ".mp3");
            }
        }
    }

    public static void LoadMusicNew(String yinyue, FightingManData fightingManData) {//System.out.println(yinyue+"模型ID");//召唤兽战斗音效
        if (yinyue != null && !yinyue.equals("")) {
            if (!Music1.equals(yinyue)) {
                String key = fightingManData.getModel().split("_")[0];
                String mp = "resource/Fightingmusic/" + key + "/" + yinyue + ".mp3";//修改战斗音效路径位置
                if (new File(mp).exists()) {
                    Music1 = yinyue;
                    Music.addyinxiaoNew(mp);
                } else {
                    String mes = fightingManData.getModel();
                    String[] mes1 = mes.split("_");
                    String aaa1 = mes1[0];
                    String aaa = fightingManData.getModel().split("_")[0];
                    Music1 = yinyue;
                    if (yinyue.equals("孩子喊话")) {
                        Music.addyinxiao(yinyue + ".mp3");
                    } else if (yinyue.equals("hit")) {
                        if (aaa.equals("70013") || aaa.equals("70009")) {
                            Music.addyinxiao("我大意了没有闪.mp3");
                        }
                    } else if (yinyue.equals("attack")) {
                        File file = new File("resource/music/" + mes1[0] + ".mp3");

                        if (!file.exists()) {
                            Music.addyinxiao("attack.mp3");
                        }


                        //【男人】
                        if (aaa.equals("20001") || aaa.equals("4294987297") || aaa.equals("81604398625") || aaa.equals("26199300525601") || aaa.equals("8589954593") || aaa.equals("85899365921")
                                || aaa.equals("2000102") || aaa.equals("2000201") || aaa.equals("81604398626") || aaa.equals("4294987298") || aaa.equals("26199300525602") || aaa.equals("12884921890")
                                || aaa.equals("90194333218") || aaa.equals("26302379740706") || aaa.equals("17179889187") || aaa.equals("94489300515") || aaa.equals("26293789806115") || aaa.equals("21474856483")
                                || aaa.equals("98784267811") || aaa.equals("26237955231267") || aaa.equals("2000305") || aaa.equals("85899365929") || aaa.equals("8589954601") || aaa.equals("26225070329385") || aaa.equals("103079235113")
                                || aaa.equals("25769823785") || aaa.equals("81604398631") || aaa.equals("4294987303") || aaa.equals("26199300525607") || aaa.equals("98784267815") || aaa.equals("21474856487")
                                || aaa.equals("500095") || aaa.equals("500101") || aaa.equals("103079255113") || aaa.equals("25769825785") || aaa.equals("1099511647787") || aaa.equals("7696581414443")
                                || aaa.equals("4294987307") || aaa.equals("30064791083")
                                || aaa.equals("20002") || aaa.equals("20003") || aaa.equals("20007") || aaa.equals("20009") || aaa.equals("20011")
                        ) {
                            Music.addyinxiao("男人攻击.mp3");
                        }

                        //【女人】
                        //【女人】
                        else if (aaa.equals("20004") || aaa.equals("34359758372") || aaa.equals("111669169700") || aaa.equals("26207890460196") || aaa.equals("115964136996") || aaa.equals("38654725668")
                                || aaa.equals("2000409") || aaa.equals("30120605666852") || aaa.equals("20005") || aaa.equals("42949692965") || aaa.equals("120259104293") || aaa.equals("26276609936933")
                                || aaa.equals("107374202405") || aaa.equals("2000507") || aaa.equals("30064791077") || aaa.equals("26212185427493") || aaa.equals("120259104294") || aaa.equals("42949692966")
                                || aaa.equals("26276609936934") || aaa.equals("47244660262") || aaa.equals("2000612") || aaa.equals("51539627558") || aaa.equals("128849038886") || aaa.equals("26216480394790") || aaa.equals("20008")
                                || aaa.equals("4294987304") || aaa.equals("81604398632") || aaa.equals("26199300525608") || aaa.equals("120259104296") || aaa.equals("42949692968") || aaa.equals("26276609936936")
                                || aaa.equals("20010") || aaa.equals("4294987306") || aaa.equals("6936372203050") || aaa.equals("26199300525610") || aaa.equals("111669169706") || aaa.equals("34359758378")
                                || aaa.equals("26207890460202") || aaa.equals("34359755378") || aaa.equals("26207890465502") || aaa.equals("42949692972") || aaa.equals("34359758380") || aaa.equals("81604398634")
                                || aaa.equals("20005") || aaa.equals("20006") || aaa.equals("20008") || aaa.equals("20010") || aaa.equals("20012")

                        ) {
                            Music.addyinxiao("女人攻击.mp3");
                        }

                        //【男仙】
                        else if (aaa.equals("22001") || aaa.equals("2200112") || aaa.equals("128849040881") || aaa.equals("51539629553") || aaa.equals("26216480396785") || aaa.equals("90194335217")
                                || aaa.equals("12884923889") || aaa.equals("26302379742705") || aaa.equals("22002") || aaa.equals("81604400626") || aaa.equals("4294989298") || aaa.equals("2200201")
                                || aaa.equals("26199300527602") || aaa.equals("64424531442") || aaa.equals("26272314971634") || aaa.equals("22003") || aaa.equals("30103425799667") || aaa.equals("26212185429491")
                                || aaa.equals("107374204403") || aaa.equals("30064793075") || aaa.equals("2200314") || aaa.equals("137438975475") || aaa.equals("60129564147") || aaa.equals("9878424802803") || aaa.equals("30107720766963")
                                || aaa.equals("128849040887") || aaa.equals("51539629559") || aaa.equals("60129564151") || aaa.equals("137438975479") || aaa.equals("81604400633") || aaa.equals("4294989305")
                                || aaa.equals("55834596857") || aaa.equals("500094") || aaa.equals("42949855305") || aaa.equals("5583455585755") || aaa.equals("30064793083") || aaa.equals("51539629563")
                                || aaa.equals("22002") || aaa.equals("22003") || aaa.equals("22007") || aaa.equals("22009") || aaa.equals("22011")
                        ) {
                            Music.addyinxiao("男仙攻击.mp3");
                        }

                        //【女仙】
                        else if (aaa.equals("22004") || aaa.equals("120259106292") || aaa.equals("42949694964") || aaa.equals("21474858484") || aaa.equals("2200405") || aaa.equals("98784269812")
                                || aaa.equals("30064793077") || aaa.equals("107374204405") || aaa.equals("68719498741") || aaa.equals("146028910069") || aaa.equals("2200516") || aaa.equals("22006")
                                || aaa.equals("81604400630") || aaa.equals("4294989302") || aaa.equals("51539629558") || aaa.equals("2200612") || aaa.equals("128849040886") || aaa.equals("146028910072")
                                || aaa.equals("68719498744") || aaa.equals("47244662264") || aaa.equals("124554073592") || aaa.equals("146028910074") || aaa.equals("68719498746") || aaa.equals("73014466042") || aaa.equals("150323877370")
                                || aaa.equals("500100") || aaa.equals("500097") || aaa.equals("73014465542") || aaa.equals("150323855370") || aaa.equals("68719498748")
                                || aaa.equals("22005") || aaa.equals("22006") || aaa.equals("22008") || aaa.equals("22010") || aaa.equals("22012")
                        ) {
                            Music.addyinxiao("女仙攻击.mp3");
                        }
                        //【男魔】
                        else if (aaa.equals("21001") || aaa.equals("30064792073") || aaa.equals("107374203401") || aaa.equals("26212185428489") || aaa.equals("128849039881") || aaa.equals("2100112")
                                || aaa.equals("51539628553") || aaa.equals("26216480395785") || aaa.equals("42949693962") || aaa.equals("120259105290") || aaa.equals("26276609937930") || aaa.equals("2100213")
                                || aaa.equals("55834595850") || aaa.equals("133144007178") || aaa.equals("26233660264970") || aaa.equals("120259105291") || aaa.equals("42949693963") || aaa.equals("26276609937931")
                                || aaa.equals("2100312") || aaa.equals("51539628555") || aaa.equals("128849039883") || aaa.equals("26216480395787") || aaa.equals("128849039887") || aaa.equals("51539628559") || aaa.equals("26216480395791")
                                || aaa.equals("17179890191") || aaa.equals("94489301519") || aaa.equals("5166845678095") || aaa.equals("120259105297") || aaa.equals("42949693969") || aaa.equals("26276609937937")
                                || aaa.equals("17179890193") || aaa.equals("94489301521") || aaa.equals("30159260373521") || aaa.equals("500093") || aaa.equals("94489551521") || aaa.equals("3015926037352")
                                || aaa.equals("42949693971") || aaa.equals("51539628563")
                                || aaa.equals("21002") || aaa.equals("21003") || aaa.equals("21007") || aaa.equals("21009") || aaa.equals("21011")
                        ) {
                            Music.addyinxiao("男魔攻击.mp3");
                        }
                        //【女魔】
                        else if (aaa.equals("21004") || aaa.equals("120259105292") || aaa.equals("42949693964") || aaa.equals("26276609937932") || aaa.equals("38654726668") || aaa.equals("115964137996")
                                || aaa.equals("26220775363084") || aaa.equals("2100409") || aaa.equals("21005") || aaa.equals("4294988301") || aaa.equals("81604399629") || aaa.equals("26199300526605")
                                || aaa.equals("2100507") || aaa.equals("30064792077") || aaa.equals("107374203405") || aaa.equals("26212185428493") || aaa.equals("111669170702") || aaa.equals("2100608")
                                || aaa.equals("34359759374") || aaa.equals("26207890461198") || aaa.equals("60129563150") || aaa.equals("9878424801806") || aaa.equals("21006") || aaa.equals("120259105296") || aaa.equals("42949693968")
                                || aaa.equals("26276609937936") || aaa.equals("124554072592") || aaa.equals("47244661264") || aaa.equals("30146375471632") || aaa.equals("21010") || aaa.equals("43001")
                                || aaa.equals("60129563154") || aaa.equals("9878424801810") || aaa.equals("115964138002") || aaa.equals("30120605667858") || aaa.equals("500098")
                                || aaa.equals("987842485510") || aaa.equals("1159641325552") || aaa.equals("38654726676") || aaa.equals("42949693972")
                                || aaa.equals("21005") || aaa.equals("21006") || aaa.equals("21008") || aaa.equals("21010") || aaa.equals("21012")
                        ) {
                            Music.addyinxiao("女魔攻击.mp3");
                        }
                        //【男鬼】
                        else if (aaa.equals("4294990297") || aaa.equals("81604401625") || aaa.equals("2300101") || aaa.equals("42949695961") || aaa.equals("120259107289") || aaa.equals("23002")
                                || aaa.equals("128849041882") || aaa.equals("51539630554") || aaa.equals("2300205") || aaa.equals("21474859482") || aaa.equals("98784270810") || aaa.equals("25769826779")
                                || aaa.equals("103079238107") || aaa.equals("2300306") || aaa.equals("55834597851") || aaa.equals("133144009179") || aaa.equals("500099") || aaa.equals("500096")
                                || aaa.equals("230055551") || aaa.equals("124554075589") || aaa.equals("42949695967") || aaa.equals("4294990303")
                                || aaa.equals("23001") || aaa.equals("23002") || aaa.equals("23003") || aaa.equals("23007")
                        ) {
                            Music.addyinxiao("男鬼攻击.mp3");
                        }
                        //【女鬼】
                        else if (aaa.equals("34359761372") || aaa.equals("111669172700") || aaa.equals("2300409") || aaa.equals("38654728668") || aaa.equals("115964139996") || aaa.equals("23005")
                                || aaa.equals("73014467037") || aaa.equals("150323878365") || aaa.equals("47244663261") || aaa.equals("2300511") || aaa.equals("124554074589") || aaa.equals("47244663262")
                                || aaa.equals("124554074590") || aaa.equals("68719499742") || aaa.equals("2300616") || aaa.equals("146028911070") || aaa.equals("500102")
                                || aaa.equals("23005556") || aaa.equals("146028955070") || aaa.equals("4294990304") || aaa.equals("68719499744")
                                || aaa.equals("23004") || aaa.equals("23005") || aaa.equals("23006") || aaa.equals("23008")
                        ) {
                            Music.addyinxiao("女鬼攻击.mp3");
                        }
                        //【男龙】
                        else if (aaa.equals("4294991297") || aaa.equals("25769827777") || aaa.equals("42949696962") || aaa.equals("51539631554") || aaa.equals("77309435331") || aaa.equals("47244664259")
                                || aaa.equals("77309435533") || aaa.equals("51539635557") || aaa.equals("4294991303") || aaa.equals("42949696967")
                                || aaa.equals("24001") || aaa.equals("24002") || aaa.equals("24003") || aaa.equals("24007")
                                || aaa.equals("154618846659") || aaa.equals("81604402625") || aaa.equals("103079239105") || aaa.equals("128849042882") || aaa.equals("120259108290")
                        ) {
                            Music.addyinxiao("男龙攻击.mp3");
                        }
                        //【女龙】
                        else if (aaa.equals("12884925892") || aaa.equals("38654729668") || aaa.equals("77309435333") || aaa.equals("51539631557") || aaa.equals("4294991302") || aaa.equals("73014468038")
                                || aaa.equals("4294995522") || aaa.equals("4294995502") || aaa.equals("73014465538") || aaa.equals("42949696968") || aaa.equals("68719500744")
                                || aaa.equals("24004") || aaa.equals("24005") || aaa.equals("24006") || aaa.equals("24008") || aaa.equals("81604402630") || aaa.equals("154618846661") || aaa.equals("128849042885")
                                || aaa.equals("90194337220") || aaa.equals("115964140996")
                        ) {
                            Music.addyinxiao("女龙攻击.mp3");
                        } else if (aaa.equals("70008")) {    //	Music.addyinxiao("女倍击打1.mp3");
                        } else if (aaa.equals("70013") || aaa.equals("70009")) {    //Music.addyinxiao("我大意了没有闪.mp3");
                            //	chatPanels.add(new FloatPanel("我大意了没有闪#4"));
                            FrameMessageChangeJpanel.addtext(0, "我大意了没有闪#4", null, fightingManData.getManname());

                            //	fightingManData.setMsg("我大意了没有闪#4");
                            //Fightingimage	if (aaa.equals("70013")&& getFightingManData().getType()==2 && part.getAct() == 6){	fightingManData.setMsg("我大意了没有闪#4");

                        } else {
                            Music.addyinxiao(aaa + ".mp3");
                        }    //其他，野怪，等等
                    } else {//System.out.println("newGWAAAA");
                        Music.addyinxiao(yinyue + ".mp3");
                    }
                }


            }
        }
    }

    /**
     * 获取随机人物数据 camp true表示同阵营 false表示不同同阵营 my true表示能选自己 false表示不能
     */
    public static Fightingimage Randomdata(boolean similar, boolean my, int man) {
        int cp = similar ? camp : EnemyCamp(camp);
        Fightingimage fightingimage = null;
        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < CurrentData.size(); i++) {
            FightingManData data = CurrentData.get(i).getFightingManData();
            if (cp == data.getCamp()) {
                if (similar && my && man == data.getMan()) {
                    continue;
                }
                a.add(i);
            }
        }
        if (a.size() != 0) {
            fightingimage = CurrentData.get(a.get(Util.random.nextInt(a.size())));
        }
        return fightingimage;
    }

    /**
     * 找到敌方阵营
     */
    public static int EnemyCamp(int camp) {
        for (int i = 0; i < CurrentData.size(); i++) {
            if (CurrentData.get(i).getFightingManData().getCamp() != camp) {
                return CurrentData.get(i).getFightingManData().getCamp();
            }
        }
        return -1;
    }

    // 添加战斗对话
    public static void Dialogue(String name, String text) {
        for (int i = 0; i < CurrentData.size(); i++) {
            if (CurrentData.get(i).getFightingManData().getType() == 0) {
                if (CurrentData.get(i).getFightingManData().getManname().equals(name)) {
                    CurrentData.get(i).Dialogue(text);
                    return;
                }
            }
        }
    }

    /**
     * 判断阵营的玩家死亡人数
     */
    public static int zyd(int camp) {
        int size = 0;
        for (int i = CurrentData.size() - 1; i >= 0; i--) {
            FightingManData data = CurrentData.get(i).getFightingManData();
            if (camp == data.getCamp() && data.getType() == 0 && data.getHp_Current() <= 0) {
                size++;
            }
        }
        return size;
    }

    /**
     * 获取战斗中列表
     */
    public static List<String> dwd(int camp) {
        List<String> buffer = new ArrayList<>();
        // 获取带头的
        for (int i = CurrentData.size() - 1; i >= 0; i--) {
            FightingManData data = CurrentData.get(i).getFightingManData();
            if (camp == data.getCamp() && data.getType() == 0 && data.getMan() == 2) {
                buffer.add(data.getManname());
                break;
            }
        }
        for (int i = CurrentData.size() - 1; i >= 0; i--) {
            FightingManData data = CurrentData.get(i).getFightingManData();
            if (camp == data.getCamp() && data.getType() == 0 && data.getMan() != 2) {
                buffer.add(data.getManname());
            }
        }
        return buffer;
    }

    /**
     * true 表示会掉 判断战斗类型是否会掉血法忠诚
     */
    public static boolean isFightType() {
        if (BattleType == 5 || BattleType == 11 || BattleType == 12 || BattleType == 31 || BattleType == 33
                || BattleType == 34) {
            return false;
        }
        return true;
    }

    /**
     * 增加召唤兽的忠诚度，100满忠诚   ,总血量
     */
    public static void addPetFathifulHP(RoleSummoning roleSummoning) throws IOException {
        int[] pets = PetProperty.getPetHMASp(roleSummoning);
        // 当前血量
        if (roleSummoning!=null) {
            long petHp = roleSummoning.getBasishp();
            // 总血量
            long sumhp = pets[0];
            // 全部加满需要的金钱
            // 先判断当前的血量和忠诚度是否都满
            if (petHp >= sumhp) {
                // 提示已满信息
                //ZhuFrame.getZhuJpanel().addPrompt2("您携带的召唤兽血量和忠诚度都已满！！");
            } else {
                // 当前余额够用来将召唤兽的忠诚度进行修复
                // 将当前召唤兽忠诚度设置为满
//				roleSummoning.setFaithful(100);
                // 设置血量为满
                roleSummoning.setBasishp(Integer.parseInt(sumhp+""));
                // 设置返回的信息
                NpcCureBean npcCureBean = new NpcCureBean();
                // 设置此时召唤兽的信息
                npcCureBean.setRoleSummoning(roleSummoning);
                // 将选中的召唤兽设置为当前状态的召唤兽
                UserMessUntil.setChosePetMes(roleSummoning);
                // 返回给服务器信息
                String messString = Agreement.npccureAgreement(GsonUtil.getGsonUtil().getgson().toJson(npcCureBean));
                // 向服务器发送信息
                SendMessageUntil.toServer(messString);
                // 刷新召唤兽血条
                Article.souxie(UserMessUntil.getChosePetMes());
                // 刷新召唤兽面板
                PetAddPointMouslisten.showPetValue();
            }
        }
    }

    /**
     * 增加召唤兽的忠诚度，100满忠诚   ,总lMP
     */
    public static void addPetFathifulMP(RoleSummoning roleSummoning) throws IOException {
        int[] pets = PetProperty.getPetHMASp(roleSummoning);
        // 当前蓝量
        if(roleSummoning!=null) {
            long petMp = roleSummoning.getBasismp();
            // 总蓝量
            int summp = pets[1];
            // 全部加满需要的金钱
            // 先判断当前的血量和忠诚度是否都满
            if (petMp >= summp) {
                // 提示已满信息
                //ZhuFrame.getZhuJpanel().addPrompt2("您携带的召唤兽血量和忠诚度都已满！！");
            } else {
                // 设置血量为满
                roleSummoning.setBasismp(summp);
                // 设置返回的信息
                NpcCureBean npcCureBean = new NpcCureBean();
                // 设置此时召唤兽的信息
                npcCureBean.setRoleSummoning(roleSummoning);
                // 将选中的召唤兽设置为当前状态的召唤兽
                UserMessUntil.setChosePetMes(roleSummoning);
                // 返回给服务器信息
                String messString = Agreement.npccureAgreement(GsonUtil.getGsonUtil().getgson().toJson(npcCureBean));
                // 向服务器发送信息
                SendMessageUntil.toServer(messString);
                // 刷新召唤兽血条
                Article.souxie(UserMessUntil.getChosePetMes());
                // 刷新召唤兽面板
                PetAddPointMouslisten.showPetValue();
            }
        }
    }

    // 宝宝回蓝  玉枢返虚丸
    public static String getMp() {
        String msg = "";
        PrivateData data = RoleData.getRoleData().getPrivateData();
        String v = data.getTimingGood();
        if (v == null || "".equals(v)) {
            return "X";
        }
        String[] vs = v.split("\\^");
        for (int i = 0; i < vs.length; i++) {
            String[] vss = vs[i].split("#");
            Limit limit = new Limit();
            for (int j = 0; j < vss.length; j++) {
                if (j == 0) {
                    limit.setName(vss[j]);
                } else if (j == 1) {
                    limit.setType(vss[j]);
                } else if (j == 2) {
                    limit.setSkin(vss[j]);
                } else if (j == 3) {
                    long time = Long.parseLong(vss[j]);
                    if (time < 100000000) {
                        time *= 60000;
                    } else if (time < 2000000000) {
                        time *= 1000;
                    }
                    limit.setTime(time);
                } else if (j == 4) {
                    limit.setValue(vss[j]);
                }
            }
            if ("玉枢返虚丸".equals(limit.getType())) {
                msg = limit.getType();
                break;
            }
        }
        return msg;
    }

    // 宝宝回蓝  六脉化神丸
    public static String getHp() {
        String msg = "";
        PrivateData data = RoleData.getRoleData().getPrivateData();
        String v = data.getTimingGood();
        if (v == null || "".equals(v)) {
            return "X";
        }
        String[] vs = v.split("\\^");
        for (int i = 0; i < vs.length; i++) {
            String[] vss = vs[i].split("#");
            Limit limit = new Limit();
            for (int j = 0; j < vss.length; j++) {
                if (j == 0) {
                    limit.setName(vss[j]);
                } else if (j == 1) {
                    limit.setType(vss[j]);
                } else if (j == 2) {
                    limit.setSkin(vss[j]);
                } else if (j == 3) {
                    long time = Long.parseLong(vss[j]);
                    if (time < 100000000) {
                        time *= 60000;
                    } else if (time < 2000000000) {
                        time *= 1000;
                    }
                    limit.setTime(time);
                } else if (j == 4) {
                    limit.setValue(vss[j]);
                }
            }
            if ("六脉化神丸".equals(limit.getType())) {
                msg = limit.getType();
                break;
            }
        }
        return msg;
    }

    static {
        CorrectTime = 0L;
        State = 0;
        BattlefieldPlay = new HashMap();
        skills = new ArrayList();
        CurrentData = new ArrayList();
        systime = System.currentTimeMillis();
        cha = 0L;
        buffUtil = new BuffUtil();
        camp = 1;
        man = -1;
//        zdhh = 0;
//        Music1 = "";
        MAX = 30;
        di = "第 ";
        bout = " 回合";
        se = Integer.toString(CurrentRound);
        seInt = CurrentRound;
        imageIconMap = new HashMap();
        x = -1;
        y = -1;
    }
}